<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">
    <ui:define name="content">
        <h:form  >
            <p:focus id="selectFocus" for="lstSelect"  />
            <p:focus id="detailFocus" for="txtName" />
            <p:panel header="Manage Report Format Categories" >
                <p:panelGrid columns="2"  styleClass="alignTop">
                    <p:panel  >
                        <p:selectOneListbox   id="lstSelect"   value="#{reportFormatController.current}" styleClass="listBox">
                            <f:selectItems  value="#{reportFormatController.items}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                            <f:ajax render=":#{p:component('gpDetail')}" execute="lstSelect" >
                            </f:ajax>
                        </p:selectOneListbox>
                        <p:commandButton id="btnAdd" ajax="false" value="Add" action="#{reportFormatController.prepareAdd()}" styleClass="buttons" onclick="onSubmitButton();"  >
                        </p:commandButton>
                        <p:commandButton id="btnDelete" ajax="false" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                    return false;" action="#{reportFormatController.delete()}"  value="Delete"  >
                        </p:commandButton>
                    </p:panel>
                    <p:panel  style="float: right;display: block;">
                        <h:panelGrid id="gpDetail" columns="2" >
                            <h:outputText id="lblName" value="Name" ></h:outputText>
                            <p:inputText autocomplete="off" id="txtName" value="#{reportFormatController.current.name}"  ></p:inputText>
                            <h:outputText id="lblCode" value="Code" >                                        
                            </h:outputText>
                            <p:inputTextarea id="txtCode"  value="#{reportFormatController.current.description}"  >
                            </p:inputTextarea>
                            <p:commandButton ajax="false" id="btnSave" value="Save" action="#{reportFormatController.saveSelected()}" styleClass="buttons" onclick="onSubmitButton();" >
                            </p:commandButton>
                            <p:defaultCommand target="btnSave"/>
                        </h:panelGrid>
                    </p:panel>
                </p:panelGrid>
            </p:panel>
        </h:form>
    </ui:define>

</ui:composition>